import { DataTypes } from 'sequelize'
const seq = require('../db/seq')

const RoleModels: any = seq.define('role', {
  identity: {
    type: DataTypes.INTEGER,
    allowNull: false,
    primaryKey: true
  },
  label: {
    type: DataTypes.STRING(45),
    allowNull: false
  },
  role_name: {
    type: DataTypes.STRING(45),
    allowNull: true,
    unique: "role_name_UNIQUE"
  },
  state: {
    type: DataTypes.INTEGER,
    allowNull: false,
    defaultValue: 1,
    comment: "状态：1，正常；0，停用"
  },
  describes: {
    type: DataTypes.STRING(255),
    allowNull: true
  }
}, {
  tableName: 'role',
  timestamps: false,
  indexes: [
    {
      name: "PRIMARY",
      unique: true,
      using: "BTREE",
      fields: [
        { name: "identity" },
      ]
    },
    {
      name: "identity_UNIQUE",
      unique: true,
      using: "BTREE",
      fields: [
        { name: "identity" },
      ]
    },
    {
      name: "role_name_UNIQUE",
      unique: true,
      using: "BTREE",
      fields: [
        { name: "role_name" },
      ]
    },
  ]
});

module.exports = RoleModels